Skip to content

Surface still-running extensions during MTP shutdown (refs #5345) - #8582

Merged
Amaury Levé (Evangelink) merged 4 commits into
mainfrom
dev/amauryleve/mtp-shutdown-progress
Jun 2, 2026
Merged

Surface still-running extensions during MTP shutdown (refs #5345)#8582
Amaury Levé (Evangelink) merged 4 commits into
mainfrom
dev/amauryleve/mtp-shutdown-progress

Conversation

@Evangelink

Copy link
Copy Markdown
Member

Closes part of #5345 (incremental improvement, complementary to the phased-shutdown RFC in #8580).

Problem

Today when a user hits Ctrl+C on a hanging MTP test run, the cancellation token gets signalled but the user has no visibility into which extension or consumer is blocking the shutdown. The process just appears stuck.

Approach

Add a small IShutdownProgressReporter service that:

  1. Tracks units of in-flight shutdown work via using (reporter.Track(uid, displayName, phase)) { await ... }.
  2. Once the test-application cancellation token fires, waits a short quiet window (3s) to avoid noise on clean shutdowns.
  3. Then periodically (every 1s) emits a Still waiting for: <Name1> (<Phase1>, <Ns>); <Name2> ... warning through IOutputDevice.

The three known blocking await sites are now wrapped:

  • ITestSessionLifetimeHandler.OnTestSessionFinishingAsync (non-consumer pass) — CommonTestHost
  • ITestSessionLifetimeHandler.OnTestSessionFinishingAsync (consumer pass) — CommonTestHost
  • IAsyncConsumerDataProcessor.DrainDataAsync per consumer — AsynchronousMessageBus

This is intentionally complementary to #8580. The RFC there proposes a full phased-shutdown protocol with a graceful timer and forced abort. The same trackers introduced here will feed the eventual Force-killed because X didn't drain message in that bigger work — but in the meantime this PR ships value independently with zero behavior change on the happy path.

Limitations

  • Does not surface slow user test code (only platform extensions/consumers expose Uid/DisplayName).
  • Output uses WarningMessageOutputDeviceData (yellow text); coordination with the live progress line is best-effort.
  • Strings are localized via PlatformResources.resx / regenerated .xlf files.

Tests

7 new unit tests in ShutdownProgressReporterTests covering snapshot semantics, idempotent dispose, quiet-window behavior, post-cancellation emission, no-emit-if-all-disposed, and post-disposal Track. All pass on net9.0 and net462.

Out of scope

  • Server-mode / IPC progress propagation.
  • CLI options to tune the quiet window or poll interval (constants for now).
  • Acceptance-test coverage (would require a long-sleeping fake extension; deferring until the RFC lands).

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants